<?php $this->load->view('layout/header_data_form');?>
<?php $this->load->view('layout/logo');?>
<?php 
$year_birth	=	date('Y',strtotime($_SESSION['customer']['date_of_birth']));
$current_age	=	date('Y')-$year_birth;

?>
<script>

function monthly()
{
	$.ajax({
	   type: "POST",
	   url: "<?php echo base_url().'retirement/monthly'?>",
	   data: "value="+$("#textfield5").val()+"&re_age="+$("#re_age").val()+"&inflation="+$("#inflation").val(),
	   success: function(msg){
	     $('#textfield4').val(msg);
	   }
	 });
}

function tinh_nam_nghi_huu()
{
	var re_age	=	parseInt($('#re_age').val());
	var age		=	parseInt(<?php echo $current_age;?>);
	$('#textfield3').val(re_age-age);
}


</script>
<div id="wrap">
  <form id="form1" name="form1" method="post" action="">
    <table border="0" cellpadding="5" cellspacing="0">
      <tr>
        <td width="500" align="left" valign="top"><table border="0" cellpadding="7" cellspacing="0">
          <tr>
            <td align="right"><strong>Desired Monthly Income (Present Value):</strong></td>
            <td><input onblur="monthly()" onfocus="" value="<?php echo($row ? $row['desired_monthly_income'] : '');?>" name="textfield5" type="text" class="field" id="textfield5" size="40" /></td>
          </tr>
          <tr>
            <td align="right"><strong>Retirement Age:</strong></td>
            <td><input onblur="tinh_nam_nghi_huu();monthly()" onfocus="tinh_nam_nghi_huu()" value="<?php echo($row ? $row['retirement_age'] : ($paramter ? $paramter->retirement_age : 60));?>" name="textfield" type="text" class="field" id="re_age" size="40" /></td>
          </tr>
          <tr>
            <td align="right"><strong>Years to Retirement:</strong></td>
            <td><input disabled="disabled" value="<?php echo($row ? $row['years_to_retirement'] : '');?>" name="textfield3" type="text" class="field" id="textfield3" size="40" /></td>
          </tr>
          <tr>
            <td align="right"><strong>Monthly Income at Retirement Age (Future Value):</strong></td>
            <td><input disabled="disabled" value="<?php echo($row ? $row['monthly_income_at_retirement_age'] : '');?>" name="textfield4" type="text" class="field" id="textfield4" size="40" /></td>
          </tr>
          <tr>
            <td align="right"><strong>Number of years to receive:</strong></td>
            <td><input value="<?php echo($row ? $row['number_of_years_to_receive'] : '');?>" name="textfield6" type="text" class="field" id="textfield6" size="40" /></td>
          </tr>
          <!--<tr>
            <td align="right"><strong>Lump sum needed:</strong></td>
            <td><input name="textfield2" type="text" class="field" id="textfield2" size="40" /></td>
          </tr>-->
          <tr>
            <td align="right"><strong>Inflation:</strong></td>
            <td><input onblur="monthly()" value="<?php echo($row ? $row['inflation'] : '');?>" name="inflation" type="text" class="field" id="inflation" size="40" /></td>
          </tr>
          <tr>
            <td align="right">&nbsp;</td>
            <td>
            	<input type="hidden" name="submit" value="0"/>
            	<button class="large button green" onClick="showhide('graph', 'block'); return false">Calculate</button>
            </td>
          </tr>
          <tr>
            <td align="left">&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td align="left" valign="top">
        
                        <div id="graph" style="display:<?php echo ($_POST ? 'block' : 'block');?>">
<br />
<br />
 </form>
 <?php 
 $this->load->view('retirement/chart');
 ?>
 		<form method="post" action="">
            <table border="0" cellpadding="7" cellspacing="0">
	              <tr>
	                <td align="left"><strong>Explanation:</strong></td>
	              </tr>
	              <tr>
	                <td align="left"><textarea name="explanation" cols="60" rows="6" class="field" id="textfield3"><?php echo($row ? $row['explanation'] : '');?></textarea></td>
	              </tr>
	              <tr>
	                <td align="right">
	                	<input type="hidden" name="submit" value="1"/>
	                	<input type="submit" class="large button red" value="Submit"/>
	                </td>
	              </tr>
	          </table>
          </form>

<br />
</div>
        </td>
      </tr>
      <tr>
        <td align="left" valign="top"><a href="JavaScript:window.close();"><img src="<?php echo img_link('cwindow.jpg');?>" alt="Close Window" width="82" height="15" border="0" /></a></td>
      </tr>
    </table>
 
  
  
</div>
<?php $this->load->view('layout/footer_data_form');?>